home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d1 / joymouse.arc / JOYBIOS.ASM < prev    next >
Assembly Source File  |  1985-07-18  |  1KB  |  73 lines

  1. stack   segment para stack 'stack'
  2.     db    128 dup(?)       ;needed only for clean assemble
  3. stack    ends
  4. int60s    segment para public 'code'
  5. int60    proc    far
  6.     assume  cs:int60s,ss:stack
  7. ; establish interrupt 60 vector (this is the joystick interrupt)
  8.         mov    dx,offset int_60
  9.     add    dx,100H
  10.     mov    ax,2560H
  11.     int    21H
  12. ; terminate and stay resident
  13.     mov    dx,offset end60
  14.         add     dx,100H
  15.     int    27H
  16. ; interrupt 60 - request joystick data to ds:dx
  17. int_60: push    ax               ;save environment
  18.     push    bx
  19.     push    cx
  20.     push    dx
  21.     push    si
  22. ;
  23.     mov    si,dx            ;set up parameters to talk to joystick
  24.     mov    bx,000fh
  25.     mov    cx,0101h
  26.     mov    dx,0201h
  27. ;
  28.     cli             ;start joystick conversation
  29.     out    dx,al
  30. NEXTIN:
  31.     in    al,dx
  32.     and     al,0fh           ;look at all joystick data
  33. cmp    al,bl
  34.     loopz    NEXTIN
  35.     jcxz    STOPIN           ;nothing else to look at
  36.     xor    al,bl
  37.     mov    ah,cl
  38.     push    ax               ;save joystick count
  39.     inc    bh
  40.     xor    bl,al
  41.     jmp    NEXTIN
  42. STOPIN: sti                      ;noting else to look at
  43. ;
  44.     or    bh,bh
  45.     jz    EXIT
  46.     mov    dl,bh
  47. OTHER:
  48.     mov    bx,si            ;calculate joystick value
  49.     mov    cx,4
  50.     pop    ax
  51.     not    ah
  52.     add    ah,dl
  53. NEXT:
  54.     shr    al,1
  55.     jnb    NOSAVE
  56.     mov    ¢bx|,ah          ;save joystick data at ds:dx +
  57. NOSAVE:
  58.     inc    bx
  59.     loop    NEXT
  60.     dec    dl
  61.     jnz    OTHER
  62. EXIT:
  63.     pop    si               ;restore environment, back to caller
  64.     pop    dx
  65.     pop    cx
  66.     pop    bx
  67.     pop    ax
  68.     iret
  69. end60    db      0
  70. int60   endp
  71. int60s    ends
  72.     end    int60
  73.